/*
 * @Author: Aro
 * @Date: 2024-02-05 10:45:23
 */
import 'package:flutter/material.dart';

class TabBarTopKit extends StatefulWidget {
  const TabBarTopKit({super.key});

  @override
  State<TabBarTopKit> createState() => _TabBarTopKit();
}

class _TabBarTopKit extends State<TabBarTopKit>
    with SingleTickerProviderStateMixin {
  late TabController _tabController;
  List tabs = ['关注', '推荐', 'NBA', '苏州', '发现', '体育', '国际', '热榜', '畅听'];

  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: tabs.length, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        TabBar(
          controller: _tabController,
          isScrollable: true,
          tabAlignment: TabAlignment.start,
          tabs: tabs.map(
            (e) {
              return Tab(
                child: Text('$e'),
              );
            },
          ).toList(),
        ),
        Expanded(
          child: TabBarView(
            controller: _tabController,
            children: tabs.map(
              (e) {
                return Container(
                  alignment: Alignment.center,
                  color: Colors.deepOrangeAccent,
                  child: Text(
                    '$e',
                    style: const TextStyle(fontSize: 30),
                  ),
                );
              },
            ).toList(),
          ),
        ),
      ],
    );
  }
}
